<template>
  <div class="video-details">
    <div class="video-bg" :style="{backgroundImage: 'url(' + filmDetails.bgImgUri + ')'}"></div>
    <div class="video-content">
      <div class="item-content safe-width">
        <div class="item-name">{{filmDetails.filmName}}<span>({{filmDetails.onlineTime}})</span></div>
        <div class="item-details">
          <div style="overflow: hidden;">
            <div class="item-details-img">
              <img :src="filmDetails.imgUri" alt="">
            </div>
            <div class="item-details-intro">
              <div>
                <div>
                  <p class="item-details-name"><span>片名:</span>
                    <template v-if="typeof filmDetails.filmName === 'string'">
                      <em>{{filmDetails.filmName}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.filmName">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-director"><span>导演:</span>
                    <template v-if="typeof filmDetails.director === 'string'">
                      <em>{{filmDetails.filmName}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.director">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-scriptwriter"><span>编剧:</span>
                    <template v-if="typeof filmDetails.scriptwriter === 'string'">
                      <em>{{filmDetails.scriptwriter}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.scriptwriter">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-protagonist"><span>主演:</span>
                    <template v-if="typeof filmDetails.protagonist === 'string'">
                      <em>{{filmDetails.protagonist}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.protagonist">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-type"><span>类型:</span>
                    <template v-if="typeof filmDetails.type === 'string'">
                      <em>{{filmDetails.type}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.type">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-country"><span>制片国家/地区:</span>
                    <template v-if="typeof filmDetails.country === 'string'">
                      <em>{{filmDetails.country}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.country">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-language"><span>语言:</span>
                    <template v-if="typeof filmDetails.language === 'string'">
                      <em>{{filmDetails.language}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.language">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-year"><span>上映日期:</span>
                    <template v-if="typeof filmDetails.year === 'string'">
                      <em>{{filmDetails.year}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.year">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                  <p class="item-details-film-length"><span>片长:</span>
                    <em>{{filmDetails.length}}分钟</em>
                  </p>
                  <p class="item-details-film-oname"><span>又名:</span>
                    <template v-if="typeof filmDetails.oname === 'string'">
                      <em>{{filmDetails.oname}}</em>
                    </template>
                    <template v-else v-for="item in filmDetails.oname">
                      <em>{{item}}</em>
                      <i>/</i>
                    </template>
                  </p>
                </div>
                <div class="item-details-btn">
                  <div>
                    <el-button type="primary" plain @click="playVideos">立即观看</el-button>
                  </div>
                 <div>
                   <el-button plain>立即下载</el-button>
                 </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="item-details-recommend item-bottom-item">
          <h2 class="title-h2">剧情介绍:</h2>
          <p class="indent-p">{{filmDetails.filmIntro}}</p>
        </div>
        <div class="item-bottom-item">
          <h2 class="title-h2">演员列表: <span>查看更多</span></h2>
          <div style="width: 100%;">
            <ul class="item-bottom-img-ul">
              <li v-for="o in filmDetails.protagonistList" :key="o.id" class="item-bottom-img-item">
                <img :src="o.imgUri" alt="">
                <p>{{o.name}}</p>
              </li>
            </ul>
          </div>
        </div>
        <div class="item-bottom-item">
          <h3 class="title-h3">{{filmDetails.filmName}}短评:</h3>
          <template v-for="item in filmEvaluate">
            <div class="item-evaluate">
              <div class="item-evaluate-top">
                <span class="item-evaluate-name">{{item.name}}</span>
                <span class="item-evaluate-star" style="margin-top: 11px">
                  <el-rate
                    v-model="item.rate"
                    disabled
                    show-score
                    text-color="#ff9900"
                    score-template="{value}">
                  </el-rate>
                </span>
                <span class="item-evaluate-date">{{item.timesp}}</span>
              </div>
              <div class="item-evaluate-middle">
                <p class="indent-p">{{item.content}}</p>
              </div>
              <div class="item-evaluate-bottom">
                <span class=""><i class="el-icon-arrow-up"></i>赞({{item.comment}})</span>
                <span><i class="el-icon-arrow-down"></i></span>
              </div>
            </div>
          </template>
        </div>
      </div>
    </div>
    <video-modal
      :videoVisible="videoVisible"
      :videoOptions="videoOptions"
      @cancelVideoModal="cancelVideoModal">
    </video-modal>
  </div>
</template>

<script>
import { mapActions } from 'vuex'
import videoModal from './videoModal'
export default {
  name: "video-details",
  data () {
    return {
      filmDetails: {},
      filmEvaluate: [],
      videoVisible: false,
      videoOptions: {
        videoUrl: '',
        state: false
      }
    }
  },
  components: {
    videoModal
  },
  created () {
    this.doGetFilmDetail()
    this.doGetFilmEvaluate()
  },
  methods: {
    playVideos () {
      this.videoVisible = true
      this.videoOptions.state = false
    },
    cancelVideoModal () {
      this.videoOptions.state = true
      this.videoVisible = false

    },
    doGetFilmDetail () {
      this._getFilmDetail({a: 1})
        .then((res) => {
          this.filmDetails = res.data.result
          this.videoOptions.videoUrl = this.filmDetails.videoUri
        })
        .catch((err) => {
          return Promise.reject(err)
        })
    },
    doGetFilmEvaluate () {
      this._getFilmEvaluate({a: 1})
        .then((res) => {
          this.filmEvaluate = res.data.result
        })
        .catch((err) => {
          return Promise.reject(err)
        })
    },
    ...mapActions(['_getFilmDetail', '_getFilmEvaluate'])
  }
}
</script>

<style scoped lang="less">
.video-details{
  .video-bg{
    width: calc(100% + 40px);
    margin-top: -20px;
    margin-left: -20px;
    overflow: hidden;
    height: 360px;
    background-color: #ffffff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
    position: relative;
    &:after{
      position: absolute;
      content: '';
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,.4);
    }
  }
  .video-content{
    position: absolute;
    width: calc(100% - 40px);
    .item-content{
      margin-top: -80px;
      .item-name{
        height: 80px;
        line-height: 80px;
        color: #f6f6f6;
        font-size: 28px;
        margin-bottom: 20px;
        span{
          margin-left: 20px;
          font-size: 22px;
          color: #dcd9d9;
        }
      }
      .item-details{
        height: 420px;
        margin-bottom: 20px;
        position: relative;
        .item-details-img{
          position: absolute;
          top: 0px;
          left: 0px;
          width: 300px;
          height: 420px;
          background: #000;
          img{
            width: 100%;
          }
        }
        .item-details-intro{
          position: absolute;
          top: 0px;
          left: 0px;
          bottom: 0px;
          right: 0px;
          padding-left: 380px;
          margin-bottom: 20px;
          &>div{
            padding: 30px 0;
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
            &>div{
              width: 50%;
              overflow: hidden;
            }
            .item-details-btn{
              display: flex;
              flex-direction: column;
              justify-content: space-around;
              align-items: center;
              div{
                height: 100px;
                line-height: 100px;
              }
            }
            p{
              line-height: 35px;
              font-size: 14px;
              span{
                padding-right: 20px;
              }
              i{
                padding: 0 5px;
              }
            }
          }
        }
      }
    }
  }
}
.item-bottom-item{
   margin-bottom: 20px;
  .title-h2{
    font-size: 20px;
    line-height: 60px;
    padding-right: 20px;
    span{
      display: inline-block;
      float: right;
      font-size: 12px;
    }
  }
  .title-h3{
    font-size: 16px;
    margin-bottom: 20px;
  }
  .indent-p{
    text-indent: 28px;
    line-height: 36px;
  }
  .item-bottom-img-ul{
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    .item-bottom-img-item{
      width: 180px;
      height: 282px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      img{
        width: 100%;
        height: 252px;
      }
      p{
        height: 30px;
        line-height: 30px;
        text-indent: 0px;
      }
    }
  }
 }
.item-evaluate{
  padding: 15px;
  border-bottom: 1px solid #ddd;
  .item-evaluate-top{
    height: 40px;
    line-height: 40px;
    .item-evaluate-name{

    }
    .item-evaluate-date{
      font-size: 12px;
      color: #646464;
    }
    span{
      display: inline-block;
      float: left;
      margin-right: 20px;
    }
  }
  .item-evaluate-middle{
    margin:20px 0;
  }
  .item-evaluate-bottom{
    height: 40px;
    line-height: 40px;
    span{
      padding: 6px 15px;
      background: rgba(0, 132, 255, 0.1);
      color: #0084ff;
      margin-right: 15px;
      border-radius: 4px;
      i{
        margin-right: 5px;
      }
    }
  }
}
</style>
